package la.bbs558.entity.enums;

import la.bbs558.exception.MsgException;
import la.bbs558.util.Objs;
import lombok.Getter;

import java.util.*;

@Getter
public enum UserOpt {
    SET_AVATAR("设置头像",  1),
    SET_TEL("手机验证", 2),
    SET_EMAIL("邮箱验证", 3),
    PROMOTION("注册推广",4),
    HIGH_LIGHT("加精", 5),
    REPLY("发表回复",6),
    POST("发表帖子", 7),
    LIKE_REPLAY("点赞回复",  8),
    LIKE_POST("点赞帖子",  9),
    COLLECT_REPLAY("收藏回复", 10),
    COLLECT_POST("收藏帖子", 11),
    ;

    private final String desc;
    private final Integer code;

    private final static List<UserOpt> enums = Arrays.asList(values());

    UserOpt(String desc, Integer code) {
        this.desc = desc;
        this.code = code;
    }

    public static UserOpt getByName(String optType){
        for (UserOpt value : enums) {
            if(Objs.equal(value.name(),optType)){
                return value;
            }
        }
        throw new MsgException("不存在此枚举");
    }



    public static List<Map<String, Object>> getPointsTypeList() {
        List<Map<String, Object>> list = new ArrayList<>();
        for (UserOpt value : UserOpt.values()) {
            Map<String, Object> map = new HashMap<>(2);
            map.put("label", value.getDesc());
            map.put("value", value.name());
            list.add(map);
        }
        return list;
    }
}

